
const app = getApp();
Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    iconList: [{
      icon: 'cardboardfill',
      color: 'red',
      badge: 120,
      name: '美食'
    }, {
      icon: 'recordfill',
      color: 'orange',
      badge: 1,
      name: '风景'
    }, {
      icon: 'picfill',
      color: 'yellow',
      badge: 0,
      name: '购物'
    }, {
      icon: 'noticefill',
      color: 'olive',
      badge: 22,
      name: '科教'
    }, {
      icon: 'upstagefill',
      color: 'cyan',
      badge: 0,
      name: '医疗'
    }, {
      icon: 'clothesfill',
      color: 'blue',
      badge: 0,
      name: '住宿'
    }, {
      icon: 'discoverfill',
      color: 'purple',
      badge: 0,
      name: '教育'
    }, {
      icon: 'questionfill',
      color: 'mauve',
      badge: 0,
      name: '帮助'
    }, {
      icon: 'commandfill',
      color: 'purple',
      badge: 0,
      name: '问答'
    }, {
      icon: 'brandfill',
      color: 'mauve',
      badge: 0,
      name: '版权'
    }],
    gridCol:3,
    skin: false
  },
    /**
   * 生命周期函数--监听页面加载
   */
  onLoad:function(option){
    var that = this
   //1.通过用户搜索关键词获取位置信息
    wx.request({
     url: 'https://restapi.amap.com/v3/place/text?parameters', //仅为示例，并非真实的接口地址
     data: {
       key: 'c380063f0f90287cd28dae048c071090',
       keywords: '白云区'
     },
     header: {
       'content-type': 'application/json' // 默认值
     },
     success (res) {
       console.log(res.data.pois[0].location) //获取用户搜索关键词的位置信息（经纬度坐标）

       //2.通过位置信息获取周边的POI信息
       wx.request({
         url: 'https://restapi.amap.com/v3/place/around?parameters ', //仅为示例，并非真实的接口地址
         data: {
           key: 'c380063f0f90287cd28dae048c071090',
           location: res.data.pois[0].location
         },
         header: {
           'content-type': 'application/json' // 默认值
         },
         success (res) {
           console.log(res.data.pois)
           // 将通过高德API获取到的周边信息存放到页面当中
           that.setData({
             pois:res.data.pois
           })
         }
       })
     }
   })
 }
 
})